package com.pinyoumei.app.activity.giftbag;

import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.FirstBean;
import com.pinyoumei.app.bean.GiftBagBean;

import java.util.List;

/**
 * Created by Administrator on 2021-08-09.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-08-09        Administrator             新增Person类
 * 2021-08-09        Administrator             增加sex属性
 */
public class GiftBagAdapter extends BaseQuickAdapter<GiftBagBean.ResultBean.GiftBagDto, BaseViewHolder> {
    public GiftBagAdapter(int layoutResId, @Nullable List<GiftBagBean.ResultBean.GiftBagDto> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GiftBagBean.ResultBean.GiftBagDto item) {
        ImageView iv_pt_goods_img = helper.getView(R.id.gift_bg_image);
        Glide.with(mContext).load(item.getGoods_img()).into(iv_pt_goods_img);
        helper.setText(R.id.gift_bg_title,item.getGoods_name());
        helper.setText(R.id.gift_bg_tag,"" + item.getTag());
        helper.setText(R.id.gift_bg_discount,item.getSale_price());
        helper.setText(R.id.gift_bg_price,"¥" + item.getMarket_price());
        TextView marketPrice = helper.getView(R.id.gift_bg_price);
        marketPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        TextView tagIcon = helper.getView(R.id.gift_bg_tag);
        if(TextUtils.isEmpty(item.getTag())){
            tagIcon.setVisibility(View.INVISIBLE);
        }else {
            tagIcon.setVisibility(View.VISIBLE);
        }
    }
}
